﻿package net.wangit.support.action;

import net.wangit.context.ActionContext;
import net.wangit.context.ActionContextHelper;
import net.wangit.jdbc.DB;
import net.wangit.jdbc.Table;
import net.wangit.util.Checker;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * Action元素未指定Action类时，此类为默认值，执行命令行逻辑。
 * 
 * @author watson Feb 25, 2010
 */
public class DefaultAction extends TransactionAction {

	private static final Log log = LogFactory
			.getLog(net.wangit.support.action.DefaultAction.class);

	public DefaultAction() {
	}

	// 执行命令行。
	public void doAction(DB db, ActionContext ac) throws Exception {
		java.util.List<Table> tables = ac.getTables();
		if (Checker.isEmpty(tables)) {
			log.debug(new StringBuilder(
					"Action cound't find any table by action: ").append(
					ActionContextHelper.getActionId(ac)).toString());
		} else {
			db.save(tables);
		}
	}

}
